import json

from django.http import HttpResponse

from .models import KeyValueStore


def get_current_config(request, key_name):
    try:
        kv = KeyValueStore.objects.get(key=key_name)
        print(kv.value)
        print(type(kv))
        return HttpResponse(
            json.dumps(kv.value),
            content_type='application/json')
    except KeyValueStore.DoesNotExist:
        return {}
